import { createBrowserRouter} from "react-router-dom"
import Reg,{action as regAction} from "@/views/auth/reg"
import Login,{action as loginAction} from "@/views/auth/login"
import Root ,{loader as rootLoader}from "@/views/root/root"
import AuthLayout from "@/views/auth/auth-Layout"
import AuthRoot from "@/views/root/auth-root"
import Home from "@/views/home/home"
import UserAvatar from "@/views/user/user-avatar"
import UserInfo from "@/views/user/user-info"
import UserPassword from "@/views/user/user-password"
import ArticleAdd from "@/views/article/art-add"
import ArticleEdit from "@/views/article/art-edit"
import ArticleList from "@/views/article/art-list"
import ArticleCate from "@/views/article/art-cate"

const router = createBrowserRouter([
    {
        path:'/reg',
        action:regAction,
        element:(
            <AuthLayout>
                <Reg/>
            </AuthLayout>)},
    {
        path:'/login',
        action:loginAction,
        element:(
            <AuthLayout>
                <Login/>
            </AuthLayout>)},
    {
        path:'/',
        element:(
            <AuthRoot>
                <Root/>
            </AuthRoot>
        ),
        loader:rootLoader,
        children:[
            //索引路由
            {index:true,element:<Home/>},
            {path:'home',element:<Home/>},
            {path:'user-info',element:<UserInfo/>},
            {path:'user-avatar',element:<UserAvatar/>},
            {path:'user-pwd',element:<UserPassword/>},
            {path:'art-cate',element:<ArticleCate/>},
            {path:'art-list',element:<ArticleList/>},
            {path:'art-add',element:<ArticleAdd/>},
            {path:'art-edit/:id',element:<ArticleEdit/>}
        ]
    }
])
    
export default router